<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    <script type="text/javascript" src="/{$admindir}/public/js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="/{$admindir}/public/js/msgbox/msgbox.js"></script>
    <script type="text/javascript" src="/{$admindir}/public/js/common.js"></script>
    <link type="text/css" href="/{$admindir}/public/js/msgbox/msgbox.css" rel="stylesheet" />
    <link type="text/css" href="/{$admindir}/public/css/style.css" rel="stylesheet" />
    <link type="text/css" href="/{$admindir}/public/css/base.css" rel="stylesheet" />
    <link type="text/css" href="/{$admindir}/public/css/base_new.css" rel="stylesheet" />
    <script type="text/javascript" src="/{$admindir}/public/js/config.js"></script>
</head>

<body style=" overflow: hidden">

   <div class="s-main">
       <form id="frm">
      <ul class="info-item-block">
          <li>
              <span class="f-l item-text">功能开关：</span>
              <div class="f-l w400">
                  <span class="item-text"><input type="radio" name="cfg_sms_number_short_hint_open" {if $configs['cfg_sms_number_short_hint_open']==1}checked="checked"{/if} value="1"/>开启</span>
                  <span class="item-text ml-10"><input type="radio" name="cfg_sms_number_short_hint_open" {if $configs['cfg_sms_number_short_hint_open']==0}checked="checked"{/if} value="0"/>关闭</span>
              </div>
          </li>
          <li>
              <span class="f-l item-text">短信低于：</span>
              <div class="f-l w400">
                  <input type="text" class="input-text w60" name="cfg_sms_number_short_hint_min" value="{$configs['cfg_sms_number_short_hint_min']}"/>条时提醒
              </div>
          </li>
          <li>
              <span class="f-l item-text">提醒人员：</span>
              <div class="f-l w400">
                     <select class="select w100" name="cfg_sms_number_short_hint_admin_id" id="admin_sel_con">
                         <option value="">请选择...</option>
                         {loop $admin_list $admin}
                          <option value="{$admin['id']}" {if $configs['cfg_sms_number_short_hint_admin_id']==$admin['id']}selected="selected"{/if}  data-phone="{$admin['phone']}">{$admin['username']}</option>
                         {/loop}
                     </select>
              </div>
          </li>
          <li>
              <span class="f-l item-text">提醒内容：</span>
              <div class="f-l w400">
                   <span class="item-text">【站点名称】的短信已不足50条，为避免对网站运营产生影响，请及时购买短信</span>
              </div>
          </li>
      </ul>
           </form>
       <div class="clearfix text-c">
           <a href="javascript:;" class="btn btn-default radius c-999 mr-10 refuse" id="refuse-btn">取消</a>
           <a href="javascript:;" class="btn btn-primary radius" id="confirm-btn">确定</a>
       </div>
   </div>
    <script>
        window.SITEURL = "{php echo URL::site();}";
        $(function(){
            var id="{$id}";
            window.setTimeout(function(){
                ST.Util.resizeDialog('.s-main');
            },0);

            $("#admin_sel_con").change(function(){
                var sel_ele = $(this).find('option:selected');
                var phone = sel_ele.attr('data-phone');
                var val = sel_ele.attr('value');
                if(val!='' && (!phone || phone==null || phone==''))
                {
                    ST.Util.showMsg('该管理员没有手机号，请及时设置',5,1200);
                }
            })


            $(document).on('click','#confirm-btn,#refuse-btn',function(){
                var audit_description = $("#audit_description").val();

                if($(this).is("#confirm-btn"))
                {

                    var isopen = $("input:radio[name=cfg_sms_number_short_hint_open]:checked").val();
                    var min_num = $("input[name=cfg_sms_number_short_hint_min]").val();
                    var admin_id = $("select[name=cfg_sms_number_short_hint_admin_id]").val();
                    if(isopen==1)
                    {
                        if(min_num<=0)
                        {
                            ST.Util.showMsg('数量不能小于0',5,1000);
                            return;
                        }
                        if(admin_id=='' || admin_id==null)
                        {
                            ST.Util.showMsg('未选择提醒人员',5,1000);
                            return;
                        }
                    }

                    var data=$("#frm").serialize();
                    $.ajax({
                        type: 'POST',
                        data: data,
                        url: SITEURL + 'sms/ajax_save_number_short?provider_id={$_GET['provider_id']}',
                        dataType: 'json',
                        success: function (data)
                        {
                            ST.Util.closeDialog();
                        }
                    });
                }
                else
                {
                    ST.Util.closeDialog();
                }
            })

        })

    </script>

</body>
</html>
